package huawei.od;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class StringSummary {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String inputStr = in.nextLine();
        inputStr = inputStr.toLowerCase();
        int[] charCount = new int[128];
        String newInputStr = "";
        for(int i=0;i<inputStr.length();i++){
            if(Character.isLetter(inputStr.charAt(i))){
                charCount[inputStr.charAt(i)] += 1;
                newInputStr += inputStr.charAt(i);
            }
        }

        inputStr = newInputStr + " ";

        List<Letter> result = new ArrayList<>();
        char preChar = inputStr.charAt(0);
        int repeat = 1;
        charCount[preChar]--;

        for(int i=1;i<inputStr.length();i++){
            char curChar = inputStr.charAt(i);
            charCount[curChar]--;
            if(curChar == preChar){
                repeat++;
            }else{
                result.add(new Letter(preChar, repeat > 1? repeat: charCount[preChar]));
                preChar = curChar;
                repeat = 1;
            }
        }

        result.sort((a,b)->{
            if(a.charCount == b.charCount){
                return a.name - b.name;
            }
            return b.charCount - a.charCount;
        });

        String resultStr = "";
        for(Letter letter : result){
            resultStr += String.valueOf(letter.name) + letter.charCount;
        }
        System.out.println(resultStr);
        return;
    }

    static class Letter{
        char name;
        int charCount;
        public Letter(char name, int charCount){
            this.name = name;
            this.charCount = charCount;
        }
    }
}
